//
//  UIImage+XJImage.m
//  weiboOC
//
//  Created by 徐绩 on 16/5/2.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "UIImage+XJImage.h"

@implementation UIImage (XJImage)

+(UIImage *)getScreenShot{

    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    CGRect frame = window.frame;
    
    //开启图形上下文
    UIGraphicsBeginImageContextWithOptions(frame.size, false, 1);
    
    //将内容渲染到图形上下文
    [window drawViewHierarchyInRect:frame afterScreenUpdates:YES];
    
    //获取图片
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    
    //关闭上下文
    UIGraphicsEndImageContext();
    
    return img;
}



@end
